<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>  
	<script type="text/javascript">
		function add(){
			var name= document.getElementById("name").value;
			var price= document.getElementById("price").value;
			var comment = document.getElementById("comment").value;
			if(name!=null && name!="" && price!=null && price!="" && comment!=null && comment!=""){
				window.location.href="<%=basePath%>"+ "Servlet/ROSServlet?req=add_class&name="+ name + "&price="+ price + "&comment="+ comment;
			}else{
				alert("请正确输入菜单项！");
				document.getElementById("name").focus();
			}
		}

function deleteMenu(){
	var id= document.getElementById("id").value;
	var reg=/^[0-9]+$/;
	var result= reg.test(id);
	if(!result){
		alert("请正确输入菜单号！");
		document.getElementById("id").focus();
		id="";
	}else{
		window.location.href="<%=basePath%>"+"Servlet/ROSServlet?req=del_class&class=" +id;
	}
}
function jump1(){
	window.location.href="<%=basePath%>"  + "main.jsp";
}
</script>
<head>
	<base href="<%=basePath%>">

	<title>菜单管理页面</title>

</head>

<body>
	<table width="100%" border="0" cellspacing="0" cellpadding="" align="">
		<tr>
			<td height="20" align="center">
				<div title="菜单管理"><strong><font face="楷体_GB2312" size="6">菜单管理</font><br></strong></div>
			</td>
		</tr>
		<c:if test="${not empty menuList}">
		<c:forEach items="${menuList}"  var="list">
		<tr>
			<td height="20">
				<c:out value="${list}"></c:out>
			</td>
		</tr>
		</c:forEach>
		</c:if>
	</table>
	<br>
	<br>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td height="20">
				菜名：<input type="text" id ="name" value="" />
			</td>
			<td height="20">
				价格：<input type="text" id ="price" value="" />
			</td>
			<td height="20">
				内容：<input type="text" id ="comment" value="" /><input type="button" id="add" value="添加" onclick="javascript:add()">
			</td>
		</tr>
		<tr>
			<td height="20" align="center">

				<br></td>
		</tr>
	</table>

	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td height="20" align="left">
				删除菜名编号：<input type="text" id ="id" value="" /><input type="button" id="add" value="删除" onclick="javascript:deleteMenu()">
			</td>
		</tr>
		<tr>
			<td height="20">

				<br></td>
		</tr>
		<tr>
			<td height="50" align="center">
				<input type="button" id='back' value='返回' align="middle" height="30" width="500px" onclick="javascript:jump1()" />
			</td>
		</tr>
	</table>
</body>
</html>
